package com.lagou.client;

import com.lagou.handler.UserClientHandler;
import com.lagou.request.RpcRequest;
import com.lagou.service.IUserService;

/**
 * @author wuyuhan
 * @date 2021/1/13 11:23
 */
public class ConsumerThread implements Runnable {

    public ConsumerThread(UserClientHandler handler, RPCConsumer rpcConsumer) {
        this.handler = handler;
        this.proxy= (IUserService) rpcConsumer.createNewProxy(handler,IUserService.class);
    }
    private IUserService proxy;
    private UserClientHandler handler;
    @Override
    public void run() {
        RpcRequest rpcRequest = new RpcRequest();
        rpcRequest.setRequestId("1111");
        rpcRequest.setClassName("userServiceImpl");
        rpcRequest.setMethodName("sayHello");
        rpcRequest.setParameterTypes(new Class[]{String.class});
        rpcRequest.setParameters(new Object[]{"rpcRequest"});
        String s = proxy.comeOn(rpcRequest);
        System.out.println(s);
    }

    public UserClientHandler getHandler() {
        return handler;
    }

    public void setHandler(UserClientHandler handler) {
        this.handler = handler;
    }
}
